package pl.edu.mimuw.irs.rcp.controller.editor.roles.handler;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CommandStack;

import pl.edu.mimuw.irs.core.model.design.resource.Role;
import pl.edu.mimuw.irs.rcp.controller.command.AbstractPersistenceSelectionHandler;
import pl.edu.mimuw.irs.rcp.controller.editor.roles.command.DeleteRoleCommand;
import pl.edu.mimuw.irs.rcp.persistence.PersistenceManager;

public class DeleteRoleHandler extends AbstractPersistenceSelectionHandler {

	// *** Attributes
	
	// *** Methods

	@Override
	public Object execute(ExecutionEvent event, CommandStack stack,
			PersistenceManager manager, Object[] selection) {
		
		for (Object object : selection) {
			if (object instanceof Role) {
				Role role = (Role) object;
				Command command = new DeleteRoleCommand(role, manager);
				stack.execute(command);
			}
		}
		
		return null;
	}
}
